
var lowercase = 'abcdefghijklmnopqrstuvwxyz';
var numbers = '0123456789';
var uppercase = lowercase.toUpperCase();
var numberFlag = confirm ("Do you want numbers in your password? ");
var uletterFlag = confirm ("Do you want uppercase letters in your password? ");
var lletterFlag = confirm ("Do you want lowercase letters in your password? ");
var possibleChars = ' ';

if (numberFlag == true){
	possibleChars +=numbers;
	}
if (lletterFlag == true){
	possibleChars +=lowercase;
	}
if (uletterFlag == true){
	possibleChars +=uppercase
	}	
	
var y = possibleChars.length;
var pwLength = prompt ("Enter the length of your password");
pwLength = parseInt(pwLength);

var password = [];
var i = 0;
while (i< pwLength) {
password [i] = possibleChars.charAt(Math.floor(Math.random()*y));
i++;

}

for (var x = 0; x < pwLength; x++){

document.write(password [x]);
}
